package com.smt.ejb3.tutoria.client;

import javax.naming.InitialContext;
import javax.naming.NamingException;

import com.smt.ejb3.tutoria.entitybean.singletable.Animal;
import com.smt.ejb3.tutoria.entitybean.singletable.Bird;
import com.smt.ejb3.tutoria.entitybean.singletable.Pig;
import com.smt.ejb3.tutoria.service.MappingService;

public class AnimalClient {
	public static void main(String[] args) {
		
		Animal a = new Animal();
		a.setName("animal");
		
		Bird b = new Bird();
		b.setName("bird");
		b.setWing("My Wing");
		
		Pig p = new Pig();
		p.setName("pig");
		p.setFoot("My Foot");
		
		Animal ab = new Bird();
		ab.setName("Animal Bird");
		
		try {
			InitialContext ctx = new InitialContext();

			MappingService service = (MappingService) ctx
					.lookup("MappingServiceImpl/remote");
			service.saveAnimal(a);
			service.saveAnimal(b);
			service.saveAnimal(p);
			service.saveAnimal(ab);
			

		} catch (NamingException ex) {
			ex.printStackTrace();
		}
	}
}
